/**
 * this file is about commonly used command line functions
 */
package common;

/**
 * @author vladimir
 */

/*
 * class with command line shortcuts
 */
public class Cwd {
	/*
	 * function looks for variable in the array of strings and if founds
	 * variable returns next element of the array. I need this to parse command
	 * line arguments example if args = {"123", "kjehd", "-J", "234"} and
	 * variable = -J it will return 234
	 * 
	 * if args = {"123", "kjehd", "-J"} and variable = -J it will return -J
	 * 
	 * if variable is not in args it will return ""
	 */
	public static String argument(String[] args, String variable) {
		for (int i = 0; i < args.length - 1; i++) {
			if (args[i].equals(variable))
				return args[i + 1];
		}
		if (args.length == 0)
			return "";
		else if (args[args.length - 1] == variable)
			return variable;
		else
			return "";
	}
}
